<?php
require_once("dbtools.inc.php");
$id=$_COOKIE['id'];
$correct_t=$_COOKIE['correct'];

$link = create_connection();
$sql="select * from users where id=$id and status='normal'";
$result=@execute_sql($link,'zhihu',$sql);
// echo "<script>console.log('".$sql."');</script>";
$user = @mysqli_fetch_object($result)->username;
$user = $user.'thonsun123';
if($correct_t!=md5($user)){
    @mysqli_free_result($result);
    @mysqli_close($link);
    header("location:login.php");
}
$sql="select * from users where id=$id";
$result=execute_sql($link,'zhihu',$sql);
$obj=mysqli_fetch_object($result);
$username=$obj->username;
$nickname=$obj->nickname;
$email=$obj->email;
$questions=$obj->questions;
$answers=$obj->answers;
$sex=$obj->sex;

$num=rand(1,30);
$path="images/".$num.".jpg";

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="description" content="Free Bootstrap Themes by Html5xCss3 dot com - Free Responsive Html5 Templates">
    <meta name="author" content="#">

    <title>问答社区|个人信息</title>

    <!-- SmartMenus jQuery Bootstrap Addon CSS -->
    <link rel="stylesheet" href="css/menu.css">

    <!-- Custom CSS -->
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap/css/_bootswatch.scss">
    <link rel="stylesheet" type="text/css" href="css/bootstrap/css/_variables.scss">
    <link rel="stylesheet" type="text/css" href="css/custom.css">

    <!-- Custom Fonts -->
    <link rel="stylesheet" href="font-awesome-4.4.0/css/font-awesome.min.css" type="text/css">
    <link rel="stylesheet" href="css/lightbox.css">


    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<nav class="navbar navbar-expand-lg navbar-dark" style="background:#C83935;">
    <div class="center">
        <div class="collapse navbar-collapse">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item">
                    <a class="navbar-brand" href="index.php">TalkWith</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" href='index.php'><span class="fa fa-home"
                                                                      aria-hidden="true">首页</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href='submit_question.php'><span class="fa fa-pencil-square-o"
                                                                         aria-hidden="true">写问题</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="profile.php"><span class="fa fa-bell-o" aria-hidden="true">通知</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="profile.php"><span class="fa fa-user" aria-hidden="true"></span>我的</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="logout.php"><span class="fa fa-power-off" aria-hidden="true">退出</span></a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<?php
echo <<<EOT
<div class="card border-light  col-8 offset-2" style="margin-top: 30px;">
    <div class="card-body">
        <div class="center">
            <img src="$path" class="card-img-top rounded-circle small" style="height: 100px;width: 100px"/>
            <div class="center">
                <p style="font-size: large"><strong>昵称: </strong><span style="font-size: 30px;font-weight: bolder;"> $nickname </span></p>
            </div>
            <p><strong>用户名： $username </strong></p>
            <p class="text-muted"><strong>邮箱：</strong> $email </p>
        </div>
        <div class="border-top pt-3">
            <div class="row">
                <h2>修改资料</h2>
            </div>
            <div id="contact_form">
                <form name="form1" id="ff" method="post" action="info_edit.php">
                    <label>
                        <span>昵称:</span>
                        <input type="text" name="nickname" id="nickname" class="form-control" value="$nickname" required>
                    </label>
                    <label>
                        <span>邮箱:</span>
                        <input type="email" name="email"  class="form-control" value="$email" required>
                    </label>
                    <label>
                        <span>性别:</span>
                        <select name="sex">
                            <option value='男'>男</option>
                            <option value='女'>女</option>
                        </select>
                    </label>
                    <label>
                        <span>旧密码:</span>
                        <input type="password" name="old_password" class="form-control" placeholder="请输入旧密码" required>
                    </label>
                    <label>
                        <span>新密码:</span>
                        <input type="password" name="new_password" class="form-control" placeholder="请输入新密码" required>
                    </label>
                    <label>
                        <span>重复密码:</span>
                        <input type="password" name="password_again" class="form-control" placeholder="请再次输入新密码" required>
                    </label>
                    <center><input class="sendButton" type="submit" value="修改"></center>
                </form>
			</div>
        </div>
    </div>
</div>
EOT;
?>



<!-- Once the page is loaded, initialized the plugin. -->
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<!--<script type="text/javascript" src="js/jquery-2.1.1.js"></script>-->
<!--<script src="js/bootstrap.min.js"></script>-->

<!-- SmartMenus jQuery Bootstrap Addon -->
<!--<script type="text/javascript" src="js/jquery.smartmenus.bootstrap.js"></script>-->

<script src="js/lightbox-plus-jquery.min.js"></script>

<!-- Menu -->
<script src="js/script.js"></script>
</body>
</html>
